#include<iostream>
using namespace std;
#include<vector>
#include<unordered_map>
#include<algorithm>
class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        vector<vector<string>> ans;
        unordered_map<string, vector<string>> path;
        for (auto& e : strs) {
            string now = e;
            sort(now.begin(), now.end());
            path[now].push_back(e);
        }
        for (auto& e : path)
            ans.push_back(e.second);
        return ans;
    }
};